program marks
implicit none
integer :: i,n
real,dimension(30) :: x
real :: std=0,xbar=0
open(1,file='data.dat')
read(1,*) n
read(1,*) (x(i),i=1,n)
call stats(x,n,xbar,std)
write(*,*) "mean is",xbar
write(*,*) "std is",std

contains
subroutine stats(y,n,ybar,s)
real,dimension(:),intent(in) :: y
real, intent(inout) :: ybar,s
integer,intent(in) :: n
integer :: i
ybar=0;s=0 
do i=1,n
   ybar=ybar+y(i)
end do
ybar=ybar/n
do i=1,n
   s=s+(y(i)-ybar)**2
end do
s=sqrt(real(s/(n-1)))
end subroutine stats
end program marks
